<#include "/common/layout.html"> 
<@layout title="123">
<script type="text/javascript" src="/js/easyui/easyui_grid.js"></script>
<script type="text/javascript">
var datagrid;
var model_name = "/order";
var model_title="订单";
var orderStatus=["待处理","已作废","已支付","已发货","已收货","已结单"];
var payments=["在线支付","货到付款","定金支付"];
	$(function() {
		$("#edit_shop_id").combobox({    
		    url: '/shop/combobox',  
		    valueField:'id',    
    		textField:'name',     
		    width:150
		}); 
		
		datagrid=$('#form_datagrid').datagrid({
		 	url:model_name+'/grid',
		 	columns:[[    
		 		{field:'customer_id',title:'支付方式',checkbox:true},
		        {field:'shop_name',title:'商户名称',width:100},
		        {field:'order_no',title:'订单编号',width:150},
		        {field:'username',title:'购买用户',width:100},
		        {field:'postage',title:'运费(元)',width:50},
		        {field:'front_money',title:'定金(元)',width:50},
		        {field:'all_money',title:'总共价格(元)',width:90},
		        {field:'payment',title:'购买方式',width:100,
		        	formatter:function(value,row,index){
						return payments[value];
					}},
		        {field:'status',title:'状态',width:70,
		      		formatter:function(value,row,index){
			      		if(row.payment==1&&row.status==2)
			      			return "准备处理"
						return orderStatus[value];
					},
					styler: function(value,row,index){
							switch(row.status){
								case 1:return 'background-color:#3393BB;color:#fff;';break;
								case 2:return 'background-color:#6693BB;color:#fff;';break;
								case 3:return 'background-color:#9993BB;color:#fff;';break;
								case 4:return 'background-color:#bb93BB;color:#fff;';break;
								case 5:return 'background-color:#ee93BB;color:#fff;';break;
							}
				}},
				{field:'remark',title:'备注'},
		        {field:'create_time',title:'订单时间',width:150},
		        {field:'id',title:'操作',
		        formatter:function(value,row,index){
		        	var restr="";
		        	if(row.status==2){
		        		return "<a href='#' onclick='audit("+value+",3)'  class='linkbutton' icon='icon-reload' >发货</a>";
		        	}
		        	if(row.status==3||row.status==4){
		        		restr+="<a href='#' onclick='audit("+value+",5)'  class='linkbutton' icon='icon-reload' >结单</a>";
		        		return restr;
		        	}
		        }}
		    ]],
		    toolbar : "#order_toolbar",
			onLoadSuccess:function(data){
				$(".linkbutton").linkbutton();
			}
		})
	})
	
	function audit(id_,status) {
		var audit_url= model_name+"/audit/"+id_;
		if(status) audit_url+="-"+status;
		$.messager.confirm('请确认', '确认操作？', function(r) {
			if (r) {
				$.ajax({
					url : audit_url,
					dataType : 'json',
					success : function(r) {
						datagrid.datagrid('load');
						datagrid.datagrid('unselectAll');
						if (r.success) {
							$.messager.show({
								msg:r.msg,
								title:'提示'
							});
							editRow = undefined;
						} else {
							$.messager.alert("操作错误",r.msg,'error');
						}
					}
				});
			}
		});
}
</script>
<script type="text/javascript" src="/js/easyui/easyui_grid_common.js"></script>

</head>
<#include "/common/seach.html" />
<@seach>
<td>订单编号</td>
<td><input type="text" name="seachLike_a.order_no"></td>
<td>商户</td>
<td><input id="edit_shop_id" name="seach_s.id""></td> 
<td>下单时间</td>
<td>
<input name="seachGt_a.create_time"class="easyui-datebox" >-<input name="seachLt_a.create_time"class="easyui-datebox" > 
</td>
</@seach>

<div id="order_toolbar">
<#if hasView>
<a href="javascript:void(0)" id="grid_toolbar_view" onclick="view();" class="easyui-linkbutton" data-options="iconCls:'icon-redo',plain:true">查看</a>
</#if>
<#if hasDel>
<a href="javascript:void(0)" id="grid_toolbar_del" onclick="del();"class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
</#if>
<a href="javascript:void(0)"  onclick="datagrid.datagrid('reload');" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
<a href="javascript:void(0)"  onclick="datagrid.datagrid('unselectAll');" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true">取消选中</a>
</div>
</@layout>